/*
 * Copyright (C) 2015-2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/model/planet_size.h"


EXTERN_C_BEGIN


unsigned int
planet_get_width(const planet_t* p)
{
  return p->size.x;
}

unsigned int
planet_get_height(const planet_t* p)
{
  return p->size.y;
}

unsigned int
planet_get_radius(const planet_t* p)
{
  return planet_get_width(p) / 2;
}

unsigned int
planet_get_diameter(const planet_t* p)
{
  return planet_get_width(p);
}

size_2d_uint
planet_get_size(const planet_t* p)
{
  return p->size;
}


bool
planet_set_width(planet_t* p, unsigned int value)
{
  if(p == NULL || value == 0)
    {
      return false;
    }
  p->size.x = value;
  return true;
}

bool
planet_set_height(planet_t* p, unsigned int value)
{
  if(p == NULL || value == 0)
    {
      return false;
    }
  p->size.y = value;
  return true;
}

bool
planet_set_radius(planet_t* p, unsigned int value)
{
  return planet_set_diameter(p, value + value);
}

bool
planet_set_diameter(planet_t* p, unsigned int value)
{
  if(p == NULL || value == 0)
    {
      return false;
    }
  
  p->size.x = value;
  p->size.y = value;
  return true;
}

bool
planet_set_size(planet_t* p, const size_2d_uint* value)
{
  if(p == NULL || value == NULL)
    {
      return false;
    }
  
  return
    planet_set_width (p, value->x) &&
    planet_set_height(p, value->y);
}


EXTERN_C_END
